#include "trainerfactory.h"

#include <cassert>
#include <iostream>

Trainer* TrainerFactory::createTrainer(const QDomElement& element) const {
	assert(!element.isNull());
	Shape* shape = 0;
	
	// get the tag name for the current DOM element
	const QString tagName = element.tagName();
	
	// create a new object on the heap depending on the type specified by the tag
	if(tagName=="Speed")
		shape = SpeedFactory::createTrainer(element);
	
	if(tagName=="Endurance")
		shape = EnduranceFactory::createTrainer(element);
	
	if(tagName=="All Around")
		shape = AllAroundFactory::createTrainer(element);
	
	// if the schema definition and the and the type list above are in sync,
	// trainer should never be null
	assert(trainer!=0);
	
	return trainer;
	}